﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Caching;

namespace WX_Service
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetAccess_Token("","");
        }

        /// <summary>
        /// 获取access_token
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="secret"></param>
        public static string GetAccess_Token(string appId, string secret)
        {
            Cache cache = HttpRuntime.Cache;
             object o= cache["ss"];
            string access_token= cache.Get("access_token").ConvertObjToStr();
            if (access_token.Length == 0)
            {

                cache.Insert("access_token", "123", null, DateTime.MaxValue, TimeSpan.FromSeconds(20));
                access_token = "123";
            }
            return access_token;
        }
    }
}